#!/bin/bash

set -e

cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1

export readonly ARCH=${1:-amd64}
export readonly NAME=${2:-$(basename "${PWD%/*}")}
export readonly CRD_NAME=${NAME}-crd
export readonly VERSION=${3:-$(basename "$PWD")}

#helm repo add rancher https://git.rancher.io/charts
#chart_version=`echo ${VERSION} | sed 's/.//'`

#helm pull rancher-stable/rancher --version=${chart_version} -d charts/ --untar
#helm pull rancher-stable/rancher --version=${chart_version} -d charts/ --untar
# There are 500+ images in this list, too many, not suitable for building with github action.
# wget -q https://github.com/rancher/rancher/releases/download/${VERSION}/rancher-images.txt -P images/shim/

cat <<'EOF' > "charts/rancher-monitoring.values.yaml"
prometheus:
  prometheusSpec:
    retentionSize: 50GiB
    scrapeInterval: 1m
    evaluationInterval: 1m
global:
  cattle:
    clusterId: local
    clusterName: local
    url: https://rancher.abc.com.cn
EOF

